package com.learn.service;

import java.text.SimpleDateFormat;
import java.util.Date;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

/**
 * @Author:Mark
 * @Description:
 * @Date: Created on 14:19 2018-11-13
 * @Modify by:
 */
@Service
public class ScheduledTaskService {

 private static final SimpleDateFormat simpleDateFormat=new SimpleDateFormat("HH:mm:ss");

 @Scheduled(fixedRate = 5000)
 public void reportCurTime(){
   System.out.println("每隔五秒执行一次"+simpleDateFormat.format(new Date()));
 }

 @Scheduled(cron = "0 33 14 ? * *")
 public void fixedTimeExucute(){
   System.out.println("指定的时间"+simpleDateFormat.format(new Date())+"执行");
 }
}
